//46.全排序 https://leetcode-cn.com/problems/permutations/submissions/
class Solution {
public:
    void backtraing(vector<int>& nums,vector<bool>& used)
    {
        if(temp.size() == nums.size())
        {
            result.push_back(temp);
        }
        for(int i = 0; i < nums.size();i++)
        {
            if(used[i] == true)
                continue;
            used[i] = true;
            temp.push_back(nums[i]);
            backtraing(nums,used);
            used[i] = false;
            temp.pop_back();
        }
    }
    vector<vector<int>> result;
    vector<int> temp;
    vector<vector<int>> permute(vector<int>& nums) {
        vector<bool> used(nums.size(),false);
        backtraing(nums,used);
        return result;
    }
};
